/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: support usb suspend
 * Author: liwugui <liwugui1@huawei.com>
 * Create: 2023-09-07
 * Note: this file isn't compiled independently, it is included
 * in drivers/usb/core/driver.c
 */

#ifdef CONFIG_RTOS_HAL_USB_SUSPEND
static unsigned int usb_support_suspend;

#ifdef CONFIG_PM
int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
{
	int status = 0;

	if (!usb_support_suspend)
		return 0;

	unbind_marked_interfaces(udev);
	status = usb_suspend_both(udev, msg);
	return status;
}
#endif

int usb_parse_suspend(void)
{
	struct device_node *node;
	int ret;

	node = of_find_compatible_node(NULL, NULL, "arm,hisi_usb");
	if (!node)
		return 0;

	ret = of_property_read_u32(node, "support_suspend", &usb_support_suspend);
	if (ret)
		printk("[%s]didn't find support_suspend!\n",  __func__);

	return 0;
}
#endif
